package com.langchain4j.simple.config;

import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName LangChainConfig
 * @createTime 18:20:00 2025/08/11
 */
@Slf4j
@Configuration(proxyBeanMethods = false)
public class LangChainConfig {

    @Bean
    public StreamingChatModel streamingChatLanguageModel() {
        return OpenAiStreamingChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_KEY"))
                .modelName("qwq-plus")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .logRequests(true)//开启请求日志
                .logResponses(true)//开启响应日志
                .timeout(Duration.ofSeconds(10)) //设置超时时间
                .build();
    }
}
